package com.haifeng.jupiter.common.redis.config;

import com.haifeng.jupiter.common.redis.handler.RedisCacheErrorHandler;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *  缓存
 * </p>
 *
 * @author: Haifeng
 * @date: 2020-09-09
 */
@EnableCaching
@Configuration
public class CacheConfig extends CachingConfigurerSupport {

    /**
     * 缓存失败处理器，缓存失败继续执行数据库查询
     * @return CacheErrorHandler
     */
    @Override
    public CacheErrorHandler errorHandler() {
        return new RedisCacheErrorHandler();
    }
}
